﻿CREATE PROCEDURE [dbo].[GetUserProjects]
@userID INT, @all BIT
AS
if (@all = 0)
begin
	select p.ProjectID as ProjectID, name as ProjectName, Description,StatusID as Status, ActivelyUsed 
	from Projects p
	inner join ProjectMembers pm on p.ProjectID = pm.ProjectID
	where pm.UserID=@userID and p.StatusID = 1
	order by ProjectName
end
else
begin
	select p.ProjectID as ProjectID, name as ProjectName, Description,StatusID as Status, ActivelyUsed 
	from Projects p
	inner join ProjectMembers pm on p.ProjectID = pm.ProjectID
	where pm.UserID=@userID 
	order by ProjectName
end

